

********************************************************************
// descriptive table of microlevel variables 
// Meiying Li 5 August 2024

clear 
use $mydata/meiyli/Sample_Unemp_NILF_Selfemp.dta

by dname, sort: egen ndid = count(pi11) if Sample_all_emp == 1 
by dname,: egen i = rank(pi11) if Sample_all_emp == 1 
gen pctpil_CY =  i/(ndid + 1) * 100 if Sample_all_emp == 1 
drop i ndid
// sum pctpil_CY

keep if Sample_all_emp == 1 
gen parent100 = parent * 100
gen tertiary100 = tertiary * 100
gen partnered100 = partnered * 100


// weighted microlevel descriptive
tabstat  pctpil_CY   tertiary100 parent100  nhhmem17 partnered100 age  [aw = ppopwgt], by(Female) s(mean sd)
collapse  pctpil_CY   tertiary100 parent100  nhhmem17 partnered100 age  [aw = ppopwgt], by(Female dname)
tabstat   pctpil_CY   tertiary100 parent100  nhhmem17 partnered100 age , by(Female) s( min max)

// % of tertiary X parenthood by gender 
clear 
use $mydata/meiyli/Sample_Unemp_NILF_Selfemp.dta
keep if Sample_all_emp == 1 
gen NT_P = 0
replace NT_P = 100 if tertiary==0 & parent ==1 
gen NT_NP = 0
replace NT_NP = 100 if tertiary==0 & parent ==0
gen T_P = 0
replace T_P = 100 if tertiary==1 & parent ==1 
gen T_NP = 0
replace T_NP = 100 if tertiary==1 & parent ==0

tabstat   NT_P   NT_NP T_P  T_NP  [aw = ppopwgt], by(Female) s(mean)
collapse  NT_P   NT_NP T_P  T_NP  [aw = ppopwgt], by(Female dname)
tabstat   NT_P   NT_NP T_P  T_NP , by(Female) s( min max)

********************************************************************


********************************************************************
// selection equation 
clear 
use $mydata/meiyli/Sample_Unemp_NILF_Selfemp.dta
keep if Sample_all_heck ==1
gen emp100 = emp * 100
gen ykid100 = ykid * 100
gen educ1 = educ 
replace educ1 = 0 if educ !=1 
gen educ1_100 = educ1 * 100

gen educ2 = educ 
replace educ2 = 1 if educ ==2
replace educ2 = 0 if educ !=2
gen educ2_100 = educ2 * 100

gen educ3 = educ 
replace educ3 = 1 if educ ==3
replace educ3 = 0 if educ !=3
gen educ3_100 = educ3 * 100


// weighted microlevel descriptive
tabstat emp100 ykid100 transfer otherincome educ1_100 educ2_100 educ3_100 [aw = ppopwgt], by(Female) s(mean sd)
// weighted microlevel min and max at the survey level
collapse  emp100 ykid100 transfer otherincome educ1_100 educ2_100 educ3_100 [aw = ppopwgt], by(Female dname)
tabstat   emp100 ykid100 transfer otherincome educ1_100 educ2_100 educ3_100, by(Female) s( min max)

********************************************************************


********************************************************************
// Sample information: N of survey, N of country, and country-years
clear
use $mydata/meiyli/Sample_Unemp_NILF_Selfemp.dta
keep if Sample_all_emp ==1
unique cname 
unique dname 
egen tag_C = tag( cname) 
egen N_C = total(tag_C)
egen tag_CY = tag( dname) 
egen N_CY = total(tag_CY)

unique cname  if Sample_fulltime_emp==1
unique dname  if Sample_fulltime_emp==1
egen tag_Cft = tag( cname)  if Sample_fulltime_emp==1
egen N_Cft = total(tag_Cft)  if Sample_fulltime_emp==1
egen tag_CYft = tag( dname)   if Sample_fulltime_emp==1
egen N_CYft = total(tag_CYft)  if Sample_fulltime_emp==1

unique cname  if Sample_WH_emp==1
unique dname  if Sample_WH_emp==1
egen tag_Cwh = tag( cname)  if Sample_WH_emp==1
egen N_Cwh = total(tag_Cwh)  if Sample_WH_emp==1
egen tag_CYwh = tag( dname)   if Sample_WH_emp==1
egen N_CYwh = total(tag_CYwh)  if Sample_WH_emp==1

unique cname  if Sample_EXP_emp==1
unique dname  if Sample_EXP_emp==1
egen tag_Cexp = tag( cname)  if Sample_EXP_emp==1
egen N_Cexp = total(tag_Cexp)  if Sample_EXP_emp==1
egen tag_CYexp = tag( dname)   if Sample_EXP_emp==1
egen N_CYexp = total(tag_CYexp)  if Sample_EXP_emp==1

unique cname  if Sample_Public_emp==1
unique dname  if Sample_Public_emp==1
egen tag_Cpublic = tag( cname)  if Sample_Public_emp==1
egen N_Cpublic = total(tag_Cpublic)  if Sample_Public_emp==1
egen tag_CYpublic = tag( dname)   if Sample_Public_emp==1
egen N_CYpublic = total(tag_CYpublic)  if Sample_Public_emp==1

unique cname  if Sample_OCC_emp==1
unique dname  if Sample_OCC_emp==1
egen tag_Cocc = tag( cname)  if Sample_OCC_emp==1
egen N_Cocc = total(tag_Cocc)  if Sample_OCC_emp==1
egen tag_CYocc = tag( dname)   if Sample_OCC_emp==1
egen N_CYocc = total(tag_CYocc)  if Sample_OCC_emp==1


tabstat N_C  N_Cft N_Cwh N_Cexp N_Cpublic   N_Cocc   , s(n, max )
tabstat N_CY  N_CYft N_CYwh N_CYexp N_CYpublic   N_CYocc   , s(max )


/// descriptive of the additional variables 
clear
clear
use $mydata/meiyli/Sample_Unemp_NILF_Selfemp.dta
keep if Sample_all_emp ==1
gen ft100 = fulltime * 100
gen public100 = public1 * 100
gen temp100 = temp1 * 100

tab occb1, gen(occ_), if Sample_OCC_emp == 1


tabstat   ft100 [aw = ppopwgt], by(Female) s(mean sd ), if Sample_fulltime_emp==1

tabstat   workhours [aw = ppopwgt], by(Female) s(mean sd ), if Sample_WH_emp==1

tabstat   wexptl [aw = ppopwgt], by(Female) s(mean sd ), if Sample_EXP_emp==1

tabstat   public100 [aw = ppopwgt], by(Female) s(mean sd ), if Sample_Public_emp==1

tabstat    occ_* [aw = ppopwgt], by(Female) s(mean sd ), if Sample_OCC_emp==1


/// by country-year 
 
clear
use $mydata/meiyli/Sample_Unemp_NILF_Selfemp.dta
gen ft100 = fulltime * 100
collapse ft100, by(Female dname), if Sample_fulltime_emp == 1
tabstat  ft100, by(Female) s(min max )
clear 
 

use $mydata/meiyli/Sample_Unemp_NILF_Selfemp.dta
collapse workhours, by(Female dname), if Sample_WH_emp == 1
tabstat  workhours, by(Female) s(min max )
clear 
 

use $mydata/meiyli/Sample_Unemp_NILF_Selfemp.dta
collapse wexptl, by(Female dname), if Sample_EXP_emp == 1
tabstat  wexptl, by(Female) s(min max )
clear 
 

use $mydata/meiyli/Sample_Unemp_NILF_Selfemp.dta
gen public100 = public1 * 100
collapse public100, by(Female dname), if Sample_Public_emp == 1
tabstat  public100, by(Female) s(min max )
 
 
 
clear
use $mydata/meiyli/Sample_Unemp_NILF_Selfemp.dta
tab occb1, gen(occ_), if Sample_OCC_emp == 1
collapse occ_1 occ_2 occ_3 occ_4 occ_5 occ_6 occ_7 occ_8 occ_9 occ_10, by(Female dname), if Sample_OCC_emp == 1
tabstat  occ_1 occ_2 occ_3 occ_4 occ_5 occ_6 occ_7 occ_8 occ_9 occ_10, by(Female) s(min max )

********************************************************************
